deploy: Default quiet for forked systemctl
authorColin Walters <walters@verbum.org>
Mon, 30 Jun 2025 20:34:11 +0000 (16:34 -0400)
committerColin Walters <walters@verbum.org>
Mon, 30 Jun 2025 20:36:39 +0000 (16:36 -0400)
I'm checking over the codebase for places we fork children; doing
so from a library means we may end up printing to stdout/stderr
of our caller, which we shouldn't do.

- Also add an error prefix with information about the service
  if we fail

Signed-off-by: Colin Walters <walters@verbum.org>
src/libostree/ostree-sysroot-deploy.c

index 2d676be15aad27d0a31c28ca19981cacdad746bf..be6f4c0de06615f2f131c4d25e803ca14aa9c3b7 100644 (file)
@@ -3779,6 +3779,8 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, const char *osname,
                                         GCancellable *cancellable, GError **error)
 {
   GLNX_AUTO_PREFIX_ERROR ("Staging deployment", error);
+  // The service which performs finalization
+  const char *svc = "ostree-finalize-staged.service";
 
   if (!_ostree_sysroot_ensure_writable (self, error))
     return FALSE;
@@ -3787,14 +3789,14 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, const char *osname,
   if (booted_deployment == NULL)
     return glnx_prefix_error (error, "Cannot stage deployment");
 
-  const char *const systemctl_argv[]
-      = { "systemctl", "start", "ostree-finalize-staged.service", NULL };
+  const char *const systemctl_argv[] = { "systemctl", "start", "--quiet", svc, NULL };
   int estatus;
-  if (!g_spawn_sync (NULL, (char **)systemctl_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL,
-                     NULL, &estatus, error))
+  if (!g_spawn_sync (NULL, (char **)systemctl_argv, NULL,
+                     G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL,
+                     &estatus, error))
     return FALSE;
   if (!g_spawn_check_exit_status (estatus, error))
-    return FALSE;
+    return glnx_prefix_error (error, "Failed to start %s", svc);
 
   g_autoptr (OstreeDeployment) deployment = NULL;
   if (!sysroot_initialize_deployment (self, osname, revision, origin, opts, &deployment,